﻿var LocalDataPrefix = "FastExecutor_";

function SetLocalData(key, data) {
    localStorage.setItem(LocalDataPrefix + key, data);
}

function GetLocalData(key) {
    return localStorage.getItem(LocalDataPrefix + key);
}

function GetSystemTheme() {
    var Theme = GetLocalData("Theme");
    if (Theme == null) {
        Theme = 'base';
    }
    return Theme;
}

function GetVersion() {
    var version = GetLocalData("StaticFileVersion");
    if (!version || version == null || version == "undefined") {
        var nowdate = new Date();
        version = nowdate.getFullYear().toString() + "." + (nowdate.getMonth() + 1) + "." + nowdate.getDate();
    }
    return version;
}

function loadcss(url, islocal) {
    var version = GetVersion();
    if (islocal) {
        url += "?version=" + version;
    }
    document.write('<link rel="stylesheet" href= ' + url + '></link>');
}
function loadjs(url, islocal) {
    var version = GetVersion();
    if (islocal) {
        url += "?version=" + version;
    }
    document.write('<script src= ' + url + '></script>');
}

loadcss(getRootPath() + "lib/ztree/zTreeStyle/zTreeStyle.css", false)
loadcss(getRootPath() + "lib/zui/css/zui.css", false)
loadcss(getRootPath() + "lib/zui/lib/datetimepicker/datetimepicker.min.css", false)
loadcss(getRootPath() + "lib/zui/lib/chosen/chosen.min.css", false)
loadcss(getRootPath() + "lib/zui/lib/chosenicons/zui.chosenicons.min.css", false)

loadjs(getRootPath() + "lib/vue/vue.js", false)
loadjs(getRootPath() + "lib/moment/moment.min.js", false)
loadjs(getRootPath() + "lib/jquery/jquery.min.js", false)
loadjs(getRootPath() + "lib/mustache/mustache.min.js", false)
loadjs(getRootPath() + "lib/zui/js/zui.js", false)
loadjs(getRootPath() + "lib/jquerymeta/jquery.metadata.js", false)
loadjs(getRootPath() + "lib/jqueryvalidate/jquery.validate.min.js", false)
loadjs(getRootPath() + "lib/jqueryvalidate/jquery.validate.message_cn.js", false)
loadjs(getRootPath() + "lib/ztree/jquery.ztree.all.min.js", false)
loadjs(getRootPath() + "lib/ztree/jquery.ztree.exhide.min.js", false)
loadjs(getRootPath() + "lib/zui/lib/datetimepicker/datetimepicker.min.js", false)
loadjs(getRootPath() + "lib/zui/lib/chosen/chosen.min.js", false)
loadjs(getRootPath() + "lib/zui/lib/chosenicons/zui.chosenicons.min.js", false)

loadcss(getRootPath() + "theme/" + GetSystemTheme() + "/dialog.css", true)
loadjs(getRootPath() + "lib/clouddialog/dialog.js", true)
loadcss(getRootPath() + "theme/" + GetSystemTheme() + "/table.css", true)
loadjs(getRootPath() + "lib/cloudtable/table.js", true)
loadjs(getRootPath() + "lib/cloudtree/tree.js", true)
loadcss(getRootPath() + "lib/cloudtree/tree.css", true)
loadjs(getRootPath() + "lib/cloudimport/import.js", true)
loadcss(getRootPath() + "lib/cloudimport/import.css", true)
loadjs(getRootPath() + "lib/cloudupload/upload.js", true)
loadcss(getRootPath() + "lib/cloudupload/upload.css", true)
loadcss(getRootPath() + "theme/" + GetSystemTheme() + "/common.css", true)
loadjs(getRootPath() + "js/common.js", true)